﻿namespace NAGFwk.Model
{
    using System;
    using System.Collections.Generic; 
    using NAGFwk.Templates;
    using System.Linq;
    using System.Text;
    using System.Data.Entity;
    using System.Threading.Tasks;
    using NAGFwk.Model;
    
    public partial class AddressRepository:BaseManagerContext,IAddressRepository
    {
    		private bool disposed = false;
            private Model.SilkeyERPEntities context;
    
    		~AddressRepository()
    		{
    		 Dispose(false);
    		}
    		public AddressRepository()
            {
                if (this.context == null)
                    this.context = BaseObjectContext<Model.SilkeyERPEntities>.Instance.context;
            }
    		public struct AddressRelatedEntities
            {
                			   
    			      public string AddressBank { get { return "AddressBank"; } }
    			  			   
    			      public string AddressCustomer { get { return "AddressCustomer"; } }
    			          }		
    
    		//*****************************************************************************************
    		//***************************Methods By Primary Key****************************************
    		//*****************************************************************************************
    		 public NAGFwk.Templates.Address GetAddressWithAllChilds(int AddressID) 
            {
    				try
    		{
    		return context.Address.Include("AddressBank").Include("AddressCustomer").SingleOrDefault(x=>x.AddressID == AddressID);        
    		}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    		}
    			
            public NAGFwk.Templates.Address GetAddress(int AddressID) 
            {
    		try
    		{
    		return context.Address.SingleOrDefault(x=>x.AddressID == AddressID);        
    			}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    		}
    
    
    		//*****************************************************************************************
    		//***************************Methods By NAGFwk*********************************************
    		//*****************************************************************************************
    		public IEnumerable<Address> GetAll()
            {
    		try
    		{
                return context.Address.ToList();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    
            public Address GetByID(int id)
            {
    		try
    		{
                return context.Address.Find(id);
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		
            public void Insert(Address Obj)
            {		
    		try
    		{
    			
                context.Address.Add(Obj);
                Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		
            public void Delete(int id)
            {
    		try
    		{
                Address _Address = context.Address.Find(id);
                context.Address.Remove(_Address);
                Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		        public void DeleteLogical(int id)
            {
    		try
    		{
                Address Obj = GetByID(id);
                Obj.Enable = false;
    			            Update(Obj);
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    			
            public void Update(Address Obj)
            {
    		try
    		{	
                context.Entry(Obj).State = EntityState.Modified;
    			            Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }	
    
            public void Save()
            {
                context.SaveChanges();
            }
    
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposed)
                    if (disposing)
                        context.Dispose();
                this.disposed = true;
            }
    
            public void Dispose()
            {
                Dispose(true);
                GC.SuppressFinalize(this);
            }
    		  			   
    			    
    		//*****************************************************************************************
    		//***************************Methods By Related Entities***********************************
    		//*****************************************************************************************
    				public NAGFwk.Templates.Address GetAddressWithAddressBank(int AddressID) 
    				{
    				try
    				{
    				return context.Address.Include("AddressBank").SingleOrDefault(x=>x.AddressID == AddressID);  
    					}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    				}
    
    			  			   
    			    
    		//*****************************************************************************************
    		//***************************Methods By Related Entities***********************************
    		//*****************************************************************************************
    				public NAGFwk.Templates.Address GetAddressWithAddressCustomer(int AddressID) 
    				{
    				try
    				{
    				return context.Address.Include("AddressCustomer").SingleOrDefault(x=>x.AddressID == AddressID);  
    					}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    				}
    
    			  	
    }
}
namespace NAGFwk.Model
{
    using System;
    using System.Collections.Generic; 
    using NAGFwk.Templates;
    using System.Linq;
    using System.Text;
    using System.Data.Entity;
    using System.Threading.Tasks;
    using NAGFwk.Model;
    
    public partial class AddressBankRepository:BaseManagerContext,IAddressBankRepository
    {
    		private bool disposed = false;
            private Model.SilkeyERPEntities context;
    
    		~AddressBankRepository()
    		{
    		 Dispose(false);
    		}
    		public AddressBankRepository()
            {
                if (this.context == null)
                    this.context = BaseObjectContext<Model.SilkeyERPEntities>.Instance.context;
            }
    		public struct AddressBankRelatedEntities
            {
                			   
    			      public string Address { get { return "Address"; } }
    			          }		
    
    		//*****************************************************************************************
    		//***************************Methods By Primary Key****************************************
    		//*****************************************************************************************
    		 public NAGFwk.Templates.AddressBank GetAddressBankWithAllChilds(int AddressID,int BankID) 
            {
    				try
    		{
    		return context.AddressBank.Include("Address").SingleOrDefault(x=>x.AddressID == AddressID && x.BankID == BankID );        
    		}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    		}
    			
            public NAGFwk.Templates.AddressBank GetAddressBank(int AddressID,int BankID) 
            {
    		try
    		{
    		return context.AddressBank.SingleOrDefault(x=>x.AddressID == AddressID && x.BankID == BankID );        
    			}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    		}
    
    
    		//*****************************************************************************************
    		//***************************Methods By NAGFwk*********************************************
    		//*****************************************************************************************
    		public IEnumerable<AddressBank> GetAll()
            {
    		try
    		{
                return context.AddressBank.ToList();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    
            public AddressBank GetByID(int id)
            {
    		try
    		{
                return context.AddressBank.Find(id);
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		
            public void Insert(AddressBank Obj)
            {		
    		try
    		{
    			
                context.AddressBank.Add(Obj);
                Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		
            public void Delete(int id)
            {
    		try
    		{
                AddressBank _AddressBank = context.AddressBank.Find(id);
                context.AddressBank.Remove(_AddressBank);
                Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    				public void DeleteLogical(int id)
            {
              throw new NotImplementedException("La entidad carece de la propiedad ENABLE. No se puede implementar el borrado logico");
            }
    			
            public void Update(AddressBank Obj)
            {
    		try
    		{	
                context.Entry(Obj).State = EntityState.Modified;
    			            Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }	
    
            public void Save()
            {
                context.SaveChanges();
            }
    
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposed)
                    if (disposing)
                        context.Dispose();
                this.disposed = true;
            }
    
            public void Dispose()
            {
                Dispose(true);
                GC.SuppressFinalize(this);
            }
    		  			   
    			    
    		//*****************************************************************************************
    		//***************************Methods By Related Entities***********************************
    		//*****************************************************************************************
    				public NAGFwk.Templates.AddressBank GetAddressBankWithAddress(int AddressID,int BankID) 
    				{
    				try
    				{
    				return context.AddressBank.Include("Address").SingleOrDefault(x=>x.AddressID == AddressID && x.BankID == BankID );  
    					}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    				}
    
    			  	
    }
}
namespace NAGFwk.Model
{
    using System;
    using System.Collections.Generic; 
    using NAGFwk.Templates;
    using System.Linq;
    using System.Text;
    using System.Data.Entity;
    using System.Threading.Tasks;
    using NAGFwk.Model;
    
    public partial class AddressCustomerRepository:BaseManagerContext,IAddressCustomerRepository
    {
    		private bool disposed = false;
            private Model.SilkeyERPEntities context;
    
    		~AddressCustomerRepository()
    		{
    		 Dispose(false);
    		}
    		public AddressCustomerRepository()
            {
                if (this.context == null)
                    this.context = BaseObjectContext<Model.SilkeyERPEntities>.Instance.context;
            }
    		public struct AddressCustomerRelatedEntities
            {
                			   
    			      public string Address { get { return "Address"; } }
    			          }		
    
    		//*****************************************************************************************
    		//***************************Methods By Primary Key****************************************
    		//*****************************************************************************************
    		 public NAGFwk.Templates.AddressCustomer GetAddressCustomerWithAllChilds(int AddressID,int CustomerID) 
            {
    				try
    		{
    		return context.AddressCustomer.Include("Address").SingleOrDefault(x=>x.AddressID == AddressID && x.CustomerID == CustomerID );        
    		}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    		}
    			
            public NAGFwk.Templates.AddressCustomer GetAddressCustomer(int AddressID,int CustomerID) 
            {
    		try
    		{
    		return context.AddressCustomer.SingleOrDefault(x=>x.AddressID == AddressID && x.CustomerID == CustomerID );        
    			}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    		}
    
    
    		//*****************************************************************************************
    		//***************************Methods By NAGFwk*********************************************
    		//*****************************************************************************************
    		public IEnumerable<AddressCustomer> GetAll()
            {
    		try
    		{
                return context.AddressCustomer.ToList();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    
            public AddressCustomer GetByID(int id)
            {
    		try
    		{
                return context.AddressCustomer.Find(id);
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		
            public void Insert(AddressCustomer Obj)
            {		
    		try
    		{
    			
                context.AddressCustomer.Add(Obj);
                Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    		
            public void Delete(int id)
            {
    		try
    		{
                AddressCustomer _AddressCustomer = context.AddressCustomer.Find(id);
                context.AddressCustomer.Remove(_AddressCustomer);
                Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }
    				public void DeleteLogical(int id)
            {
              throw new NotImplementedException("La entidad carece de la propiedad ENABLE. No se puede implementar el borrado logico");
            }
    			
            public void Update(AddressCustomer Obj)
            {
    		try
    		{	
                context.Entry(Obj).State = EntityState.Modified;
    			            Save();
    				}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
            }	
    
            public void Save()
            {
                context.SaveChanges();
            }
    
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposed)
                    if (disposing)
                        context.Dispose();
                this.disposed = true;
            }
    
            public void Dispose()
            {
                Dispose(true);
                GC.SuppressFinalize(this);
            }
    		  			   
    			    
    		//*****************************************************************************************
    		//***************************Methods By Related Entities***********************************
    		//*****************************************************************************************
    				public NAGFwk.Templates.AddressCustomer GetAddressCustomerWithAddress(int AddressID,int CustomerID) 
    				{
    				try
    				{
    				return context.AddressCustomer.Include("Address").SingleOrDefault(x=>x.AddressID == AddressID && x.CustomerID == CustomerID );  
    					}
    		catch
    		{
    		RejectChanges(context);
    		throw;
    		}		
    				}
    
    			  	
    }
}

//*****************************************************************************************
//********************************Interface Section****************************************
//*****************************************************************************************
namespace NAGFwk.Model
{
    using System;
    using System.Collections.Generic; 
    using NAGFwk.Templates;
    using System.Linq;
    using System.Text;
    using System.Data.Entity;
    using System.Threading.Tasks;
    using NAGFwk.Model;
    
    public partial interface IAddressRepository:NAGFwk.Model.IBaseRepository<Model.Address>
    {
    		
    		//*****************************************************************************************
    		//***************************Methods By Primary Key****************************************
    		//*****************************************************************************************
    		  NAGFwk.Templates.Address GetAddressWithAllChilds(int AddressID);
    
    			
             NAGFwk.Templates.Address GetAddress(int AddressID); 
    		  			   
    			    
    	//*****************************************************************************************
    		//***************************Methods By Related Entities****************************************
    		//*****************************************************************************************
    				 NAGFwk.Templates.Address GetAddressWithAddressBank(int AddressID) ;
    				
    			  			   
    			    
    	//*****************************************************************************************
    		//***************************Methods By Related Entities****************************************
    		//*****************************************************************************************
    				 NAGFwk.Templates.Address GetAddressWithAddressCustomer(int AddressID) ;
    				
    			  }
}
namespace NAGFwk.Model
{
    using System;
    using System.Collections.Generic; 
    using NAGFwk.Templates;
    using System.Linq;
    using System.Text;
    using System.Data.Entity;
    using System.Threading.Tasks;
    using NAGFwk.Model;
    
    public partial interface IAddressBankRepository:NAGFwk.Model.IBaseRepository<Model.AddressBank>
    {
    		
    		//*****************************************************************************************
    		//***************************Methods By Primary Key****************************************
    		//*****************************************************************************************
    		  NAGFwk.Templates.AddressBank GetAddressBankWithAllChilds(int AddressID,int BankID);
    
    			
             NAGFwk.Templates.AddressBank GetAddressBank(int AddressID,int BankID); 
    		  			   
    			    
    	//*****************************************************************************************
    		//***************************Methods By Related Entities****************************************
    		//*****************************************************************************************
    				 NAGFwk.Templates.AddressBank GetAddressBankWithAddress(int AddressID,int BankID) ;
    				
    			  }
}
namespace NAGFwk.Model
{
    using System;
    using System.Collections.Generic; 
    using NAGFwk.Templates;
    using System.Linq;
    using System.Text;
    using System.Data.Entity;
    using System.Threading.Tasks;
    using NAGFwk.Model;
    
    public partial interface IAddressCustomerRepository:NAGFwk.Model.IBaseRepository<Model.AddressCustomer>
    {
    		
    		//*****************************************************************************************
    		//***************************Methods By Primary Key****************************************
    		//*****************************************************************************************
    		  NAGFwk.Templates.AddressCustomer GetAddressCustomerWithAllChilds(int AddressID,int CustomerID);
    
    			
             NAGFwk.Templates.AddressCustomer GetAddressCustomer(int AddressID,int CustomerID); 
    		  			   
    			    
    	//*****************************************************************************************
    		//***************************Methods By Related Entities****************************************
    		//*****************************************************************************************
    				 NAGFwk.Templates.AddressCustomer GetAddressCustomerWithAddress(int AddressID,int CustomerID) ;
    				
    			  }
}

//*****************************************************************************************
//********************************Functions Section****************************************
//*****************************************************************************************
          
